<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script type="text/javascript">
    // 浏览器对音谱的支持情况
        function checkAudio(){
            let myAudio = document.createElement('audio');
            if(myAudio.canPlayType) {
                if('' != myAudio.canPlayType('audio/mpeg')){
                    console.log('support mp3');
                }

                if('' != myAudio.canPlayType('audio/ogg;codecs="vorbis"')) {
                    console.log('support ogg');
                }

                if('' != myAudio.canPlayType('audio/mp4;codecs="mp4a.40.5"')) {
                    console.log('support AAC')
                }
            }else {
                console.log('not support audio check!');
            }
        }

        window.onload = function(){
            checkAudio();
        }
    </script>
</head>
<body>
    <audio controls="controls">
        <source src="src/1.mp3" type="audio/mpeg" />
        <source src="src/1.ogg" type="audio/ogg" />
        你的浏览器不支持audio!
    </audio>
</body>
</html>